
R3F_FNCT_ManageCargo = {
	private ["_box","_array","_clear_weapon","_clear_ammo","_count","_ar","_nbr","_class"];
	If (IS_Client) then {
		_box = _this select 0;
		if (typeName _box != "OBJECT") exitWith {};
		_array = _this select 1;
		if (typeName _array != "ARRAY") exitWith {};
		_clear_weapon = if (count _this > 2) then {_this select 2;} else {false;};
		if (typeName _clear_weapon != "BOOL") exitWith {};
		_clear_ammo = if (count _this > 3) then {_this select 3;} else {false;};
		if (typeName _clear_ammo != "BOOL") exitWith {};
		hint "R3F_FNCT_ManageCargo";
		if (_clear_weapon) then {clearWeaponCargo _box;};
		if (_clear_ammo) then {clearMagazineCargo _box;};
		_count = count _array;
		if (_count > 0) then {
			for [{_i = 0},{_i < _count},{_i = _i + 1}] do {
				_ar = _array select _i;
				_nbr = _ar select 1;
				if (typeName _nbr != "SCALAR") exitWith {};
				if (_nbr > 0) then {
					_class = _ar select 0;
					if ((typeName _class == "STRING") && (_class != "")) then {
						if (getText (configFile >> "CfgWeapons" >> _class >> "simulation") == "weapon") then {
							_box addWeaponCargo [_class,_nbr];
						};
						if (getText (configFile >> "CfgMagazines" >> _class >> "simulation") == "ProxyMagazines") then {
							_box addMagazineCargo [_class,_nbr];
						};
					};
				};
			};
		};	
	};
};
